import request from '@/utils/request'
//定义登录的请求体的数据类型
export interface LoginModel {
  phone: string,
  password: string
}
//定义登录的响应数据类型
export interface LoginResModel {
  code: number
  data: LoginResDataModel
  message: string
  ok: boolean
}
export interface LoginResDataModel {
  name: string
  nickName: string
  token: string
  userId: number
  loginName: string
}
export interface RegisterModel {
  phone: string,
  password: string,
  code: string
}
export interface CodeResModel {
  code: number
  data: string
  message: string
  ok: boolean
}
export default {
  //登录的api
  reqLogin: (data: LoginModel) => request.post<any, LoginResModel>('/app-dev/api/user/passport/login', data),
  //获取用户信息的api
  reqGetUserInfo: () => request.get<any, LoginResModel>('/app-dev/api/user/passport/auth/getUserInfo'),
  //退出登录的api
  reqLoginOut: () => request.get<any, LoginResModel>('/app-dev/api/user/passport/logout'),
  //注册账号的api
  reqRegister: (data: RegisterModel) => request.post<any, LoginResModel>('/app-dev/api/user/passport/register', data),
  //获取验证码
  reqGetCode: (phone: string) => request.get<any, CodeResModel>(`/app-dev/api/user/passport/sendCode/${phone}`)
}